$(function(){
	new app.table('#table',{
		url: 'json/data1.json',
	    toolbar: '#toolbar', 
	    dataType:'json',
	    height:500,
	    pagination:true,
	    checkbox:'state',
	    columns: [
	    {
	        field: 'id',
	        title: 'id'
	    }, {
	        field: 'name',
	        title: 'name',
	        sortable:true,
	    }, {
	        field: 'price',
	        title: 'price',
	        sortable:true
	    },{
              title: '操作',
              field: 'id',
              align: 'center',
              formatter:function(value,row,index){  
	            var e = '<a href="javascript:" mce_href="#" onclick="edit(\''+ row.id + '\')">编辑</a> ';  
	            var d = '<a href="javascript:" mce_href="#" onclick="del(\''+ row.id +'\')">删除</a> ';  
                return e+d;  
            } 
        } ]
	})
	//弹出iframe
	$('#layer').on('click',function(){
		app.layerIframe('title','iframe.html');
	});
	$('#layer1').on('click',function(){
		app.layermsg('提示')
	})
	$('#layer2').on('click',function(){
		app.layeralert('提示1','添加成功')
	})
	$('#layer3').on('click',function(){
		app.layerconfirm('提示1','是否删除')
	})
	$('#layer4').on('click',function(){
		app.layerprompt('提示1',3,function(val){
			app.layermsg(val);
		})
	})
	$('#layer5').on('click',function(){
		app.layerprompt('提示1',2,function(val){
			app.layermsg(val);
		})
	})
	$('#layer6').on('click',function(){
		app.layerprompt('提示1',1,function(val){
			app.layermsg(val);
		})
	})
	$('#layer7').on('click',function(){
		app.layertab('600px','300px',[{
		    title: 'TAB1', 
		    content: '内容1'
		  }, {
		    title: 'TAB2', 
		    content: '内容2'
		  }, {
		    title: 'TAB3', 
		    content: '内容3'
		}])
	})
	$('#layer8').on('click',function(){
		app.layeropen({
		  type: 1,
		  title: false,
		  closeBtn: 0,
		  shadeClose: true,
		  skin: 'yourclass',
		  content: '自定义HTML内容'
		})
	})
	$('#layer9').on('click',function(){
		app.layeropen({
		  type: 1,
		  title: false,
		  closeBtn: 0,
		  area: '516px',
		  skin: 'layui-layer-nobg', //没有背景色
		  shadeClose: true,
		  content: '<img src="http://layer.layui.com/images/tong.jpg">'
		})
	})
	if($('#tree').length>0){
		new app.tree({ele:'#tree',url:'json/tree.json',click:function(node){
		  	console.log(node);
		}})
	}
	
	//日历
	
	//滚动1
    $('#ul1').slimScroll({height:'100px'})
    //滚动2
    $("#demo").panel({iWheelStep:32});
    //导航
    new app.nav({
    	ele:'.has_sub',url:'json/nav.json'
    })
    if($('.g_header_nav').length>0){
    	new app.scrolldiv('.g_header_nav')
    }
    
    
});

$(function(){
	var n=navigator.userAgent
	var ie=n.indexOf("MSIE") != -1
	if(ie){		
		var s=/MSIE\s[6789]\./g;
		if(s.test(n)){
			fn();
		}
		try{
			if(typeof WebSocket!="function"){
				fn();
			}
		}catch(e){

		}
	}
	var root=document.documentElement;
	if(!('textShadow' in root.style) || !('transition' in root.style)){
		fn();
	}
	function fn(){
		location.href='browser.html'
	}
})
